﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PadnugRepositoryInterfaces;
using PadnugRepository;
using padnug.Domain;

namespace PadnugService
{
    public class PadnugMembershipService : IPadnugMembershipService
    {
        private IPadnugMembership _membershipRepository;

        public PadnugMembershipService(IPadnugMembership membershipRepository)
        {
            _membershipRepository = membershipRepository;

        }
        
        #region IPadnugMembershipService Members

        public bool CreateUser(PadnugUser padnugUser)
        {
            return _membershipRepository.CreateUser(padnugUser);
        }

        public bool DeleteUser(string username, bool deleteAllRelatedData)
        {
            return _membershipRepository.DeleteUser(username, deleteAllRelatedData);
        }

        public PadnugUser GetUser(string username, string password)
        {
            return _membershipRepository.GetUser(username, password);
        }

        public void UpdateUser(PadnugUser padnugUser)
        {
            _membershipRepository.UpdateUser(padnugUser);
        }

        public bool ValidateUser(string username, string password)
        {
            return _membershipRepository.ValidateUser(username, password);
        }

        public bool ChangePassword(string userName, string oldPassword, string newPassword)
        {
            return _membershipRepository.ChangePassword(userName, oldPassword, newPassword);
        }

        #endregion
    }

    public interface IPadnugMembershipService
    {
        bool CreateUser(PadnugUser padnugUser);
        bool DeleteUser(string username, bool deleteAllRelatedData);
        PadnugUser GetUser(string username, string password);
        void UpdateUser(PadnugUser padnugUser);
        bool ValidateUser(string username, string password);
        bool ChangePassword(string userName, string oldPassword, string newPassword);
    }
}
